package com.bigflexlib.x.flash.events.subscriber
{
	
	import flash.utils.Dictionary;
	

	/**
	 * 
	 * @author aldo.bucchi@gmail.com
	 * 
	 */	
	internal class AbstractEventSubscriptionCollectionStep extends AbstractEventSubscriptionStep
	{


		
		private var subElementRegistry:Dictionary;
	
	
	
		public function AbstractEventSubscriptionCollectionStep( target:Object, remainingSteps:Array )
		{

			super( target, remainingSteps );

			subElementRegistry = new Dictionary( );
		
		}
	
	
		override internal function kill( ):void
		{
		
			for ( var e:* in subElementRegistry )
			{
				( subElementRegistry[ e ] as EventSubscriptionStep ).kill( );
			}
			
			subElementRegistry = new Dictionary( );
		
		}	
	
	
	
		protected function addSubElement( e:* ):void
		{
			if ( ! subElementRegistry[ e ] )
			{
				subElementRegistry[ e ] = new EventSubscriptionStep( e, remainingSteps );
			}
		}
		
		
		
		protected function removeSubElement( e:* ):void
		{
			if ( subElementRegistry[ e ] )
			{
				( subElementRegistry[ e ] as EventSubscriptionStep ).kill( );
				delete subElementRegistry[ e ];
			}
		}
	
		
		
		
	}
	
}